module executor.notice.NoticeExecutor;

import msgtrans;
import message.Constants;
import message.MsgDefine;
import google.protobuf;
import hunt.logging;
import client.ImClient;
import std.array;
import std.conv : to;


/**
 * 未用
 */
@TransportClient(msgClientName)
class NoticeExecutor : AbstractExecutor!(NoticeExecutor){

  @MessageId(MESSAGE.CMD_NOTIFY_TRANSFER)
  void notice(TransportContext ctx, MessageBuffer buffer)
  {
    auto notice = new Notification();
    buffer.data.fromProtobuf!Notification(notice);
    TransportSession[] clients =  ImClient.getInstance().getImClient(to!ulong(notice.destination));
    logInfo("notice : %d",notice.destination);
    foreach(TransportSession client ; clients)
    {
      client.send(new MessageBuffer(MESSAGE.CMD_NOTIFY_TRANSFER,notice.toProtobuf.array));
    }
    //if (c !is null)
    //{
    //  c.send(new MessageBuffer(MESSAGE.CMD_NOTIFY_TRANSFER,notice.toProtobuf.array));
    //}else
    //{
    //  logWarning("notice user %d is offline",notice.destination);
    //}
  }
}

